package com.crossbone;

import com.crossbone.dao.UserDao;
import com.crossbone.model.User;
import com.crossbone.spring.Adder;
import de.agilecoders.wicket.core.Bootstrap;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.spring.injection.annot.SpringBean;

public class HomePage extends WebPage {

    private static final long serialVersionUID = 1L;

    @SpringBean
    Adder adder;

    @SpringBean
    UserDao dao;

    public HomePage(final PageParameters parameters) {
        super(parameters);

        add(new Label("version", getApplication().getFrameworkSettings().getVersion()));

        add(new BasicChartPanel("chartPanel"));
        // TODO Add your page's components here

        add(new Label("label", adder.add(3, 3)));

        String name = "adem" + System.currentTimeMillis();
        User user = new User(name);
        user.setActive(true);

        dao.saveUser(user);
        add(new Label("username", dao.getUser(name).getName()));

    }

    @Override
    public void renderHead(IHeaderResponse response) {
        super.renderHead(response);

        Bootstrap.renderHead(response);
    }

}
